<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">


<link rel="stylesheet" href="/blog/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('http://asura_99.gitee.io/blog').hostname,
    root: '/blog/',
    scheme: 'Gemini',
    version: '7.7.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":true,"show_result":true,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":true,"color":"#ccc","save":"auto"},
    fancybox: true,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="Java学习">
<meta property="og:type" content="article">
<meta property="og:title" content="java基本语法及例子">
<meta property="og:url" content="http://asura_99.gitee.io/blog/2020/01/07/java%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E5%8F%8A%E4%BE%8B%E5%AD%90/index.html">
<meta property="og:site_name" content="Asura的个人博客">
<meta property="og:description" content="Java学习">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://s2.ax1x.com/2020/01/07/l6jP0g.png">
<meta property="article:published_time" content="2020-01-07T07:58:27.000Z">
<meta property="article:modified_time" content="2020-01-23T12:14:18.776Z">
<meta property="article:author" content="Asura">
<meta property="article:tag" content="java">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://s2.ax1x.com/2020/01/07/l6jP0g.png">

<link rel="canonical" href="http://asura_99.gitee.io/blog/2020/01/07/java%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E5%8F%8A%E4%BE%8B%E5%AD%90/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>java基本语法及例子 | Asura的个人博客</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?09bd084d4dca15ac5ef55288d2f94bac";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Asura的个人博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">Asura</h1>
      
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/blog/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/blog/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <a href="https://gitee.com/Asura_99" class="github-corner" title="Follow me on Gitee" aria-label="Follow me on Gitee" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://asura_99.gitee.io/blog/2020/01/07/java%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E5%8F%8A%E4%BE%8B%E5%AD%90/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="http://tva1.sinaimg.cn/large/007X8olVly1g7ulgru7t4j30u00u0juk.jpg">
      <meta itemprop="name" content="Asura">
      <meta itemprop="description" content="有时候总觉得生活的矛盾让我们的生活丰富了许多：矛盾像首尾互接的鱼，在这个世界中长久地存活着。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Asura的个人博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          java基本语法及例子
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-01-07 15:58:27" itemprop="dateCreated datePublished" datetime="2020-01-07T15:58:27+08:00">2020-01-07</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-01-23 20:14:18" itemprop="dateModified" datetime="2020-01-23T20:14:18+08:00">2020-01-23</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/%E7%BC%96%E7%A8%8B%E5%AD%A6%E4%B9%A0/" itemprop="url" rel="index">
                    <span itemprop="name">编程学习</span>
                  </a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/blog/2020/01/07/java%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E5%8F%8A%E4%BE%8B%E5%AD%90/#comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/blog/2020/01/07/java%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E5%8F%8A%E4%BE%8B%E5%AD%90/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Java学习"><a href="#Java学习" class="headerlink" title="Java学习"></a>Java学习</h1><p><img src="https://s2.ax1x.com/2020/01/07/l6jP0g.png" alt="目录"></p>
<a id="more"></a>

<h2 id="新建项目"><a href="#新建项目" class="headerlink" title="新建项目"></a>新建项目</h2><p>在Project Explorer中右键，New –&gt; Other –&gt; Java Project<br>填写项目名，直接Finish就行了</p>
<h3 id="项目结构"><a href="#项目结构" class="headerlink" title="项目结构"></a>项目结构</h3><ol>
<li>新建项目（Project）</li>
<li>包: package<br>包名：<pre><code>1. 公司的域名倒着写 com.zhiyou100
2. 包的作用 goods/orders</code></pre></li>
<li>项目的组成单元,class类<br>例子：com.zhiyou100.goods<pre><code>goods_add.java</code></pre> com.zhiyou100.orders<pre><code>orders_add.java</code></pre></li>
</ol>
<h2 id="编写代码"><a href="#编写代码" class="headerlink" title="编写代码"></a>编写代码</h2><p>建好class后在编辑区编写代码，写好后保存，右键<code>Run As</code> –&gt; <code>Java Application</code>运行</p>
<h2 id="Java的基本语法"><a href="#Java的基本语法" class="headerlink" title="Java的基本语法"></a>Java的基本语法</h2><h3 id="1-关键字（50个）"><a href="#1-关键字（50个）" class="headerlink" title="1. 关键字（50个）"></a>1. 关键字（50个）</h3><p>在Java里面拥有特殊含义的，被用在特定地方的词语就是Java关键字；</p>
<ul>
<li><strong>abstract assert</strong></li>
<li><strong>boolean break byte</strong></li>
<li><strong>case catch char class const continue</strong></li>
<li><strong>default do double</strong></li>
<li><strong>else enum extends</strong></li>
<li><strong>final finally float for</strong></li>
<li><strong>goto</strong> </li>
<li><strong>if implements import instanceof int interface</strong></li>
<li><strong>long</strong> </li>
<li><strong>native new</strong></li>
<li><strong>package private protected public</strong> </li>
<li><strong>return</strong> </li>
<li><strong>strictfp short static super switch synchronized</strong></li>
<li><strong>this throw throws transient try</strong> </li>
<li><strong>void volatile</strong></li>
<li><strong>while</strong></li>
</ul>
<h3 id="2-保留字"><a href="#2-保留字" class="headerlink" title="2. 保留字"></a>2. 保留字</h3><p>现在还没有成为关键字，但是将要成为关键字；</p>
<ul>
<li>public     公共的    修饰符</li>
<li>class      类    声明类的</li>
<li>static     静态的    修饰符</li>
<li>void         没有返回值的</li>
</ul>
<h3 id="3-标识符"><a href="#3-标识符" class="headerlink" title="3. 标识符"></a>3. 标识符</h3><p>所有的类名，方法名，变量名，属性名 …；<br>所有的名字都是java标识符；</p>
<h4 id="合法的标识符"><a href="#合法的标识符" class="headerlink" title="合法的标识符"></a>合法的标识符</h4><ul>
<li><strong>只能包含字母（A-z），数字（0-9），下划线（_），美元符（$）</strong></li>
<li><strong>不能以数字开头</strong></li>
<li><strong>没有长度限制，但是不能有空格</strong></li>
<li><strong>不能使用Java关键字</strong></li>
<li><strong>区分大小写</strong></li>
</ul>
<h3 id="4-标识符的命名规范"><a href="#4-标识符的命名规范" class="headerlink" title="4. 标识符的命名规范"></a>4. 标识符的命名规范</h3><ul>
<li><strong>见名知意 起名字要有意义</strong></li>
<li><strong>类名：首字母大写，从第二个单词开始，每个单词的首字母大写</strong></li>
<li><strong>其他名字：首字母小写，从第二个单词开始，每个单词的首字母大写</strong></li>
</ul>
<p><code>例子：niHaoZhanGan / nihaozhangan</code></p>
<h3 id="5-注释"><a href="#5-注释" class="headerlink" title="5. 注释"></a>5. 注释</h3><p>给人看的对程序的解释说明（计算机不编译）</p>
<ul>
<li><strong>单行注释</strong> <code>// 内容</code></li>
<li><strong>多行注释</strong> <code>/* 内容 */</code> 用在方法里面，主要是对代码的解释说明</li>
<li><strong>文档注释</strong> <code>/** 内容 */</code> 写在类或方法的前面，对类或方法的解释说明（会显示在类或方法上）</li>
</ul>
<h3 id="6-数据类型"><a href="#6-数据类型" class="headerlink" title="6. 数据类型"></a>6. 数据类型</h3><p>数据类型的意义：<br>数字里面的类型：整数，小数，有理数，无理数，按规律划分的；<br>计算机里面的数据类型：是按内存划分的；</p>
<ul>
<li>合理声明类型能<strong>节约内存</strong>资源</li>
<li>类型不对会出bug，报错</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">graph LR</span><br><span class="line">A[数据类型] --&gt; B(基本数据类型)</span><br><span class="line">A --&gt; C(引用数据类型)</span><br><span class="line">B --&gt; D(整数类型)</span><br><span class="line">B --&gt; E(浮点类型)</span><br><span class="line">B --&gt; F(&quot;字符类型char -- 2字节&quot;)</span><br><span class="line">B --&gt; G(&quot;逻辑[布尔]类型(boolean) --- 1字节&quot;)</span><br><span class="line">D --&gt; H(&quot;字节类型(byte) -- 1字节&quot;)</span><br><span class="line">D --&gt; J(&quot;短整型（short）-- 2字节&quot;)</span><br><span class="line">D --&gt; K(&quot;整型（int）-- 4字节&quot;)</span><br><span class="line">D --&gt; L(&quot;长整型（long）-- 8字节&quot;)</span><br><span class="line">E --&gt; M(&quot;单精度（float）-- 4字节&quot;)</span><br><span class="line">E --&gt; N(&quot;双精度（double）-- 8字节&quot;)</span><br><span class="line">C --&gt; O(数组)</span><br><span class="line">C --&gt; P(类)</span><br><span class="line">C --&gt; Q(对象)</span><br><span class="line">C --&gt; R(接口)</span><br></pre></td></tr></table></figure>

<h3 id="7-变量"><a href="#7-变量" class="headerlink" title="7. 变量"></a>7. 变量</h3><ol>
<li>变量指的是内存中的某个区域</li>
<li>该区域有自己的名字</li>
<li>该区域有自己的数据类型</li>
<li>该区域里面的值可以在该类型范围内任意改变    </li>
</ol>
<h4 id="变量的命名"><a href="#变量的命名" class="headerlink" title="变量的命名"></a>变量的命名</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">数据类型 变量名;</span><br><span class="line">变量名 = 变量值</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">BianLiang</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">        * 变量的声明</span></span><br><span class="line"><span class="comment">        *</span></span><br><span class="line"><span class="comment">        * 数据类型 变量名;</span></span><br><span class="line"><span class="comment">        * 变量名 = 变量值;</span></span><br><span class="line"><span class="comment">        *</span></span><br><span class="line"><span class="comment">        * 数据类型 变量名 = 变量值;</span></span><br><span class="line"><span class="comment">        *</span></span><br><span class="line"><span class="comment">        *  */</span></span><br><span class="line">        <span class="keyword">byte</span> b = <span class="number">127</span>;   <span class="comment">// -128,127</span></span><br><span class="line">        <span class="keyword">short</span> s = <span class="number">128</span>;</span><br><span class="line">        <span class="keyword">int</span> i = <span class="number">3</span>;</span><br><span class="line">        <span class="keyword">long</span> l = <span class="number">9999999999999L</span>;    <span class="comment">// long类型的值需要在后面加L/l</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">float</span> f = <span class="number">1.0f</span>; <span class="comment">// float类型后面需要加f/F</span></span><br><span class="line">        <span class="keyword">double</span> d = <span class="number">1.0</span>;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">char</span> c = <span class="string">'a'</span>;   <span class="comment">// char类型单引号里面有且只有一个字符</span></span><br><span class="line">        </span><br><span class="line">        <span class="keyword">boolean</span> bool = <span class="keyword">true</span>;	<span class="comment">// 只有true和false</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="8-运算符"><a href="#8-运算符" class="headerlink" title="8.运算符"></a>8.运算符</h3><h4 id="算术运算符"><a href="#算术运算符" class="headerlink" title="算术运算符"></a>算术运算符</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">YunSuan</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">         <span class="comment">/*</span></span><br><span class="line"><span class="comment">    	 * 算术运算符</span></span><br><span class="line"><span class="comment">    	 * + - * / %取余，取模</span></span><br><span class="line"><span class="comment">    	 */</span></span><br><span class="line">        <span class="keyword">int</span> x = <span class="number">1324</span>;  <span class="comment">// x是一个任意数，求出各个位上的数</span></span><br><span class="line">        <span class="keyword">int</span> a = x%<span class="number">10</span>;   <span class="comment">// 个位数</span></span><br><span class="line">        <span class="keyword">int</span> b = x/<span class="number">10</span>%<span class="number">10</span>;    <span class="comment">// 十位数</span></span><br><span class="line">        <span class="keyword">int</span> c = x/<span class="number">100</span>%<span class="number">10</span>;   <span class="comment">// 百位数</span></span><br><span class="line">        System.out.println(a);</span><br><span class="line">        System.out.println(b);</span><br><span class="line">        System.out.println(c);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="条件运算符"><a href="#条件运算符" class="headerlink" title="条件运算符"></a>条件运算符</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">YunSuan</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 条件运算符 &gt; &lt; &gt;= &lt;= == != 他们返回的值是boolean类型的</span></span><br><span class="line">        <span class="keyword">int</span> a = <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">int</span> b = <span class="number">2</span>;</span><br><span class="line">        <span class="keyword">boolean</span> c = <span class="number">1</span>&lt;<span class="number">2</span>;</span><br><span class="line">        <span class="keyword">boolean</span> d = <span class="number">1</span>==<span class="number">2</span>;</span><br><span class="line"></span><br><span class="line">        System.out.println(c);</span><br><span class="line">        System.out.println(d);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="逻辑运算符"><a href="#逻辑运算符" class="headerlink" title="逻辑运算符"></a>逻辑运算符</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">YunSuan</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 逻辑运算符 &amp;与 |或 !非</span></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * &amp; 与 并且 所有的都是真的才是真的，一假即假</span></span><br><span class="line"><span class="comment">         * | 或 一真即真（）</span></span><br><span class="line"><span class="comment">         * ! 非</span></span><br><span class="line"><span class="comment">         * */</span></span><br><span class="line">        <span class="keyword">int</span> a=<span class="number">1</span>;</span><br><span class="line">        <span class="keyword">int</span> b=<span class="number">2</span>;</span><br><span class="line">        <span class="keyword">int</span> c=<span class="number">3</span>;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * &amp;和&amp;&amp;的区别</span></span><br><span class="line"><span class="comment">         * 他们的使用场景和运算结果是一样的，运算效率不一样</span></span><br><span class="line"><span class="comment">         * &amp; 不管前面的条件是真是假，后面的条件都会判断</span></span><br><span class="line"><span class="comment">         * &amp;&amp; 如果前面的条件是假的，后面的不再执行，已经是假的了</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         * | 不管前面的条件是真是假，后面的条件都会判断</span></span><br><span class="line"><span class="comment">         * || 如果前面的条件是真的，后面的不再执行</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">boolean</span> d = a&lt;b &amp; a&gt;c;</span><br><span class="line">        System.out.println(d);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="9-流程控制语句"><a href="#9-流程控制语句" class="headerlink" title="9.流程控制语句"></a>9.流程控制语句</h3><ul>
<li><p>顺序结构（默认结构）</p>
</li>
<li><p>选择结构</p>
</li>
<li><p>循环结构</p>
</li>
</ul>
<h4 id="选择结构"><a href="#选择结构" class="headerlink" title="选择结构"></a>选择结构</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 选择结构</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">IfDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * if(条件表达式--&gt; 结果是一个boolean类型)&#123;</span></span><br><span class="line"><span class="comment">         *      条件为真时执行的语句;</span></span><br><span class="line"><span class="comment">         * &#125;else&#123;</span></span><br><span class="line"><span class="comment">         *      条件为假时执行的语句;</span></span><br><span class="line"><span class="comment">         * &#125;</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="comment">// 输入谁大谁小</span></span><br><span class="line">        <span class="keyword">int</span> a = <span class="number">123</span>;</span><br><span class="line">        <span class="keyword">int</span> b = <span class="number">2324</span>;</span><br><span class="line">        <span class="keyword">if</span>(a&gt;b)&#123;</span><br><span class="line">            System.out.println(<span class="string">"a大"</span>);</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            System.out.println(<span class="string">"b大"</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 1. 判断一个数int a = 111; 是不是偶数</span></span><br><span class="line"><span class="comment">         * 2. 判断一个数是不是既能被3整除，又能被5整除</span></span><br><span class="line"><span class="comment">         * 3. 判断一个数是不是能被3整除，或者能被7整除</span></span><br><span class="line"><span class="comment">         * */</span></span><br><span class="line">        <span class="keyword">int</span> c = <span class="number">111</span>;</span><br><span class="line">        <span class="keyword">if</span>(c % <span class="number">2</span> == <span class="number">0</span>)&#123;</span><br><span class="line">            System.out.printf(<span class="string">"c=%d 能被2整除\n"</span>, c);</span><br><span class="line">        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">            System.out.printf(<span class="string">"c=%d 不能被2整除\n"</span>, c);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">int</span> d = <span class="number">60</span>;</span><br><span class="line">        <span class="keyword">if</span> (d%<span class="number">3</span> == <span class="number">0</span> &amp;&amp; d%<span class="number">5</span> == <span class="number">0</span>)&#123;</span><br><span class="line">            System.out.printf(<span class="string">"d=%d 能被3和5同时整除\n"</span>, d);</span><br><span class="line">        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">            System.out.printf(<span class="string">"d=%d 不能被3和5同时整除\n"</span>, d);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">int</span> e = <span class="number">26</span>;</span><br><span class="line">        <span class="keyword">if</span> (e%<span class="number">3</span> == <span class="number">0</span> || e%<span class="number">7</span> == <span class="number">0</span>)&#123;</span><br><span class="line">            System.out.printf(<span class="string">"e=%d 能被3或7整除\n"</span>, e);</span><br><span class="line">        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">            System.out.printf(<span class="string">"e=%d 不能被3或7整除\n"</span>, e);</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * if(条件表达式)&#123;</span></span><br><span class="line"><span class="comment">         *      条件为真执行的语句</span></span><br><span class="line"><span class="comment">         * &#125;else if(条件表达式)&#123;</span></span><br><span class="line"><span class="comment">         *      不符合之前的条件，但是符合当前条件时执行的语句</span></span><br><span class="line"><span class="comment">         * &#125;else if(条件表达式)&#123;</span></span><br><span class="line"><span class="comment">         *      ...</span></span><br><span class="line"><span class="comment">         * &#125;...&#123;</span></span><br><span class="line"><span class="comment">         *      ...</span></span><br><span class="line"><span class="comment">         * &#125;else&#123;</span></span><br><span class="line"><span class="comment">         *      前面都不符合时执行的语句</span></span><br><span class="line"><span class="comment">         * &#125;</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 如果a&gt;0输入，它是正数</span></span><br><span class="line">        <span class="keyword">int</span> f = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">if</span>(f &gt; <span class="number">0</span>)&#123;</span><br><span class="line">            System.out.println(<span class="string">"f是正数"</span>);</span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(f == <span class="number">0</span>)&#123;</span><br><span class="line">            System.out.printf(<span class="string">"f为0"</span>);</span><br><span class="line">        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">            System.out.printf(<span class="string">"f为负数"</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="循环结构"><a href="#循环结构" class="headerlink" title="循环结构"></a>循环结构</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">While(条件表达式)&#123;</span><br><span class="line">	循环体</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 循环结构</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">WhileDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 打印我爱中国100遍</span></span><br><span class="line">        <span class="comment">// 什么时候使用循环 1. 重复 2. 有规律</span></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * while(条件表达式)&#123;</span></span><br><span class="line"><span class="comment">         *      循环体</span></span><br><span class="line"><span class="comment">         * &#125;</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">int</span> a = <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">while</span> (a&lt;=<span class="number">10</span>)&#123;</span><br><span class="line">            System.out.println(<span class="string">"我爱中国"</span> + a);</span><br><span class="line">            a += <span class="number">1</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 打印1-10以内所有的偶数</span></span><br><span class="line">        <span class="keyword">int</span> c = <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">while</span> (c&lt;=<span class="number">10</span>)&#123;</span><br><span class="line">            <span class="keyword">if</span> (c%<span class="number">2</span>==<span class="number">0</span>)&#123;</span><br><span class="line">                System.out.println(c);</span><br><span class="line">            &#125;</span><br><span class="line">            c++;</span><br><span class="line">        &#125;</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 打印所有的水仙花数， 一个三位数各个位上的数字的立方和等与本身</span></span><br><span class="line">        <span class="keyword">int</span> d = <span class="number">100</span>;</span><br><span class="line">        <span class="keyword">while</span> (d&lt;=<span class="number">999</span>)&#123;</span><br><span class="line">            <span class="keyword">int</span> e = d%<span class="number">10</span>;</span><br><span class="line">            <span class="keyword">int</span> f = d/<span class="number">10</span>%<span class="number">10</span>;</span><br><span class="line">            <span class="keyword">int</span> g = d/<span class="number">100</span>%<span class="number">10</span>;</span><br><span class="line">            <span class="keyword">if</span> (e*e*e + f*f*f + g*g*g == d)&#123;</span><br><span class="line">                System.out.println(d + <span class="string">"是水仙花数"</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            d++;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="break-continue"><a href="#break-continue" class="headerlink" title="break, continue"></a>break, continue</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">BreakContinue</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">int</span> a = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">while</span> (a&lt;<span class="number">10</span>) &#123;</span><br><span class="line">            a++;</span><br><span class="line">            <span class="keyword">if</span> (a == <span class="number">5</span>) &#123;</span><br><span class="line">                <span class="comment">//break;	// 跳出所有循环</span></span><br><span class="line">                <span class="keyword">continue</span>;	<span class="comment">// 跳出此次循环</span></span><br><span class="line">            &#125;</span><br><span class="line">            System.out.println(a);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="Scanner（键盘输入，-扫描器）"><a href="#Scanner（键盘输入，-扫描器）" class="headerlink" title="Scanner（键盘输入， 扫描器）"></a>Scanner（键盘输入， 扫描器）</h4><p>作用：获取从键盘输入的内容</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ScannerDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 工具类的使用 Scanner 获取从键盘输入的内容</span></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 需要使用扫描仪的内容</span></span><br><span class="line"><span class="comment">         * 1. 我要去借别人的</span></span><br><span class="line"><span class="comment">         *    确定借谁的   1</span></span><br><span class="line"><span class="comment">         *        导包import java.util.Scanner;</span></span><br><span class="line"><span class="comment">         *    把扫描仪借来 1</span></span><br><span class="line"><span class="comment">         *    可以开始使用 n</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        Scanner scr = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line">        <span class="keyword">int</span> j = scr.nextInt();  <span class="comment">// 输入</span></span><br><span class="line">        System.out.println(<span class="string">"j="</span> + j);</span><br><span class="line">        <span class="keyword">int</span> i = scr.nextInt();</span><br><span class="line">        <span class="keyword">if</span> (i%<span class="number">2</span> == <span class="number">0</span>)&#123;</span><br><span class="line">            System.out.println(i + <span class="string">"是偶数"</span>);</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            System.out.println(i + <span class="string">"是奇数"</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="猜数字小游戏"><a href="#猜数字小游戏" class="headerlink" title="猜数字小游戏"></a>猜数字小游戏</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 猜数字的小游戏</span></span><br><span class="line"><span class="keyword">package</span> com.zhiyou100.day03;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ScannerDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//写一个猜数字的小游戏</span></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 定义一个数字 15</span></span><br><span class="line"><span class="comment">         * 如果输入的数字比15大 给出提示 大了</span></span><br><span class="line"><span class="comment">         * 如果输入的数字比15小 给出提示 小了</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">int</span> a = <span class="number">20</span>;</span><br><span class="line">        Scanner scr = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>)&#123;</span><br><span class="line">            System.out.println(<span class="string">"请输入你猜测的数字："</span>);</span><br><span class="line">            <span class="keyword">int</span> i = scr.nextInt();</span><br><span class="line">            <span class="keyword">if</span>(i&gt;a)&#123;</span><br><span class="line">                System.out.println(<span class="string">"大了"</span>);</span><br><span class="line">            &#125;<span class="keyword">else</span> <span class="keyword">if</span>(i&lt;a)&#123;</span><br><span class="line">                System.out.println(<span class="string">"小了"</span>);</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                System.out.println(<span class="string">"恭喜你，猜对了"</span>);</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="ATM"><a href="#ATM" class="headerlink" title="ATM"></a>ATM</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> java.util.Scanner;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 1.模拟ATM取款机取款流程</span></span><br><span class="line"><span class="comment"> * 	第一步：输入账号密码</span></span><br><span class="line"><span class="comment"> * 		如果账号密码错误，从新输入</span></span><br><span class="line"><span class="comment"> * 		如果账号密码正确，进入操作页面</span></span><br><span class="line"><span class="comment"> * 		选项：1.查询余额 2.取钱 3.存钱 4，退出</span></span><br><span class="line"><span class="comment"> * 	第二步：输入1,2,3,4进行相应的操作</span></span><br><span class="line"><span class="comment"> * 		取钱和存钱会修改相应的账号余额</span></span><br><span class="line"><span class="comment"> * 	初始化项目：定义：  int username账号=123</span></span><br><span class="line"><span class="comment"> * 			    Int password 密码=456</span></span><br><span class="line"><span class="comment"> *              Double banlance 余额=999;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ATMDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        Scanner scr = <span class="keyword">new</span> Scanner(System.in);</span><br><span class="line">        <span class="keyword">int</span> username = <span class="number">123</span>;</span><br><span class="line">        <span class="keyword">int</span> password = <span class="number">456</span>;</span><br><span class="line">        <span class="keyword">double</span> banlance = <span class="number">999</span>;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>)&#123;</span><br><span class="line">            System.out.println(<span class="string">"请输入账号密码：,输入0 0退出"</span>);</span><br><span class="line">            <span class="keyword">int</span> username_input = scr.nextInt();</span><br><span class="line">            <span class="keyword">int</span> password_input = scr.nextInt();</span><br><span class="line">            <span class="keyword">if</span>(username==username_input &amp;&amp; password==password_input)&#123;</span><br><span class="line">                <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">                    System.out.println(<span class="string">"请输入数字进行操作："</span>);</span><br><span class="line">                    System.out.println(<span class="string">"1.查询余额 2.取钱 3.存钱 4，退出"</span>);</span><br><span class="line">                    <span class="keyword">int</span> i = scr.nextInt();</span><br><span class="line">                    <span class="keyword">if</span> (i == <span class="number">1</span>) &#123;</span><br><span class="line">                        System.out.println(<span class="string">"您的余额为"</span> + banlance);</span><br><span class="line">                    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (i == <span class="number">2</span>) &#123;</span><br><span class="line">                        System.out.println(<span class="string">"请输入需要取得金额"</span>);</span><br><span class="line">                        <span class="keyword">while</span>(<span class="keyword">true</span>)&#123;</span><br><span class="line">                            <span class="keyword">double</span> j = scr.nextDouble();</span><br><span class="line">                            <span class="keyword">if</span>(j &gt; banlance)&#123;</span><br><span class="line">                                System.out.println(<span class="string">"余额不足！请重新输入："</span>);</span><br><span class="line">                            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                                banlance -= j;</span><br><span class="line">                                System.out.println(<span class="string">"您成功取款"</span> + j + <span class="string">"元"</span>);</span><br><span class="line">                                <span class="keyword">break</span>;</span><br><span class="line">                            &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                        System.out.println(<span class="string">"当前余额为："</span> + banlance);</span><br><span class="line">                    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (i == <span class="number">3</span>) &#123;</span><br><span class="line">                        System.out.println(<span class="string">"请输入存钱的金额："</span>);</span><br><span class="line">                        <span class="keyword">double</span> k = scr.nextDouble();</span><br><span class="line">                        banlance += k;</span><br><span class="line">                        System.out.println(<span class="string">"您成功存款"</span> + k + <span class="string">"元"</span>);</span><br><span class="line">                        System.out.println(<span class="string">"当前余额为："</span> + banlance);</span><br><span class="line">                    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (i == <span class="number">4</span>) &#123;</span><br><span class="line">                        System.out.println(<span class="string">"退出系统！"</span>);</span><br><span class="line">                        <span class="keyword">break</span>;</span><br><span class="line">                        <span class="comment">// System.exit(0);  //退出程序</span></span><br><span class="line">                    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                        System.out.println(<span class="string">"输入错误，请重新输入"</span>);</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;<span class="keyword">else</span> <span class="keyword">if</span>(username_input == <span class="number">0</span>) &#123;</span><br><span class="line">                System.out.println(<span class="string">"退出系统！"</span>);</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                System.out.println(<span class="string">"账号或密码错误，请重新输入！"</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="doWhile-循环"><a href="#doWhile-循环" class="headerlink" title="doWhile 循环"></a>doWhile 循环</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DoWhile</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * do&#123;</span></span><br><span class="line"><span class="comment">         *      循环体</span></span><br><span class="line"><span class="comment">         * &#125;while(条件表达式)</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         * 执行流程</span></span><br><span class="line"><span class="comment">         * 1. 先执行一次循环体</span></span><br><span class="line"><span class="comment">         * 2. 再判断条件表达式</span></span><br><span class="line"><span class="comment">         *      如果条件表达式为true， 执行循环体</span></span><br><span class="line"><span class="comment">         *      继续执行表达式</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="comment">// 打印1-10</span></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * int a = 1</span></span><br><span class="line"><span class="comment">         * while(a&lt;=10)&#123;</span></span><br><span class="line"><span class="comment">         *  System.out.println(a);</span></span><br><span class="line"><span class="comment">         *  a++;</span></span><br><span class="line"><span class="comment">         * &#125;</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">int</span> i = <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">do</span> &#123;</span><br><span class="line">            <span class="keyword">if</span> (i % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                System.out.println(i);</span><br><span class="line">            &#125;</span><br><span class="line">            i++;</span><br><span class="line">        &#125; <span class="keyword">while</span> (i &lt;= <span class="number">10</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="while和do-while的区别"><a href="#while和do-while的区别" class="headerlink" title="while和do-while的区别"></a>while和do-while的区别</h5><p>while是先执行条件表达式，再执行循环体；do-while先执行一次循环体，再执行条件表达式。<br>希望不管条件表达式是真是假都执行循环体一次用<code>do-while</code></p>
<h4 id="for循环"><a href="#for循环" class="headerlink" title="for循环"></a>for循环</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ForDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * for(初始化语句;条件表达式;迭代语句)&#123;</span></span><br><span class="line"><span class="comment">         *      循环体</span></span><br><span class="line"><span class="comment">         * &#125;</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         * 执行顺序：</span></span><br><span class="line"><span class="comment">         * 1. 初始化语句</span></span><br><span class="line"><span class="comment">         * 2. 条件表达式(true--&gt;3)(false--&gt;break)</span></span><br><span class="line"><span class="comment">         * 3. 循环体</span></span><br><span class="line"><span class="comment">         * 4. 迭代语句--&gt;2</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 打印1-10</span></span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> a=<span class="number">1</span>; a&lt;=<span class="number">10</span>; a++)&#123;</span><br><span class="line">            System.out.println(a);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">int</span> b=<span class="number">1</span>;</span><br><span class="line">        <span class="keyword">for</span>(; b&lt;=<span class="number">10</span>; )&#123;</span><br><span class="line">            System.out.println(b);</span><br><span class="line">            b++;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 1-10之间的偶数</span></span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> c=<span class="number">1</span>; c&lt;=<span class="number">10</span>; c++)&#123;</span><br><span class="line">            <span class="keyword">if</span> (c%<span class="number">2</span>==<span class="number">0</span>)&#123;</span><br><span class="line">                System.out.println(c + <span class="string">"是偶数"</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="10-print输出"><a href="#10-print输出" class="headerlink" title="10.print输出"></a>10.print输出</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 字符类型 char "有且只有一个字符"</span></span><br><span class="line"><span class="comment">         * 字符串类型 String 由0-多个组成的一个有序序列 "0-多个字符"</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">        String s = <span class="string">"nihao"</span>;</span><br><span class="line">        System.out.println(s);</span><br><span class="line"></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * +</span></span><br><span class="line"><span class="comment">         * 1. 表示相加</span></span><br><span class="line"><span class="comment">         *    1+2=3 在 + 两边都是基本数据类型的时候表示相加</span></span><br><span class="line"><span class="comment">         *    int a=1; int b=2; int c=a+b;</span></span><br><span class="line"><span class="comment">         * 2. 表示拼接</span></span><br><span class="line"><span class="comment">         *    "ab"+"c"="abc" 在+两边有任意一边是String类型的时候表示拼接</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line"></span><br><span class="line">        String a=<span class="string">"1"</span>;</span><br><span class="line">        <span class="keyword">int</span> b=<span class="number">1</span>;</span><br><span class="line">        System.out.println(b+<span class="number">1</span>);        <span class="comment">// 2</span></span><br><span class="line">        System.out.println(a+<span class="number">1</span>);        <span class="comment">// 11</span></span><br><span class="line">        System.out.println(<span class="string">"a"</span>+<span class="number">1</span>+<span class="number">1</span>);    <span class="comment">// a11</span></span><br><span class="line">        System.out.println(<span class="string">"a"</span>+(<span class="number">1</span>+<span class="number">1</span>));  <span class="comment">// a2</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 练习：</span></span><br><span class="line"><span class="comment">         * 1. int a=1;</span></span><br><span class="line"><span class="comment">         * 打印出 a的值是xxx</span></span><br><span class="line"><span class="comment">         * 2. int a=1; int b=2;</span></span><br><span class="line"><span class="comment">         * 打印出 a的值是1，b的值是2</span></span><br><span class="line"><span class="comment">         * 3. int a=1; int b=2;</span></span><br><span class="line"><span class="comment">         * 打印出 a+b=xxx      a+b=3</span></span><br><span class="line"><span class="comment">         * 3. int a=1; int b=2;</span></span><br><span class="line"><span class="comment">         * 打印出 a=1, b=2</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">int</span> x=<span class="number">1</span>; <span class="keyword">int</span> y=<span class="number">2</span>;</span><br><span class="line">        System.out.println(<span class="string">"x的值是"</span> + x);</span><br><span class="line">        System.out.println(<span class="string">"x的值是"</span> + x + <span class="string">"，y的值是"</span> + y);</span><br><span class="line">        System.out.println(<span class="string">"x+y="</span> + (x+y));</span><br><span class="line">        System.out.println(<span class="string">"x="</span> + x + <span class="string">", y="</span> + y);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="11-赋值运算"><a href="#11-赋值运算" class="headerlink" title="11.赋值运算"></a>11.赋值运算</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">FuZhiDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 赋值运算符 = += -= *= /= %=</span></span><br><span class="line">        <span class="keyword">int</span> a = <span class="number">1</span>;</span><br><span class="line">        <span class="comment">/*a += 1;</span></span><br><span class="line"><span class="comment">        a *= 2;</span></span><br><span class="line"><span class="comment">        a /= 2;</span></span><br><span class="line"><span class="comment">        System.out.println(a);*/</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * a++ 和 ++a都是自增1</span></span><br><span class="line"><span class="comment">         * a++是先运算再自增</span></span><br><span class="line"><span class="comment">         * ++a是先自增再运算</span></span><br><span class="line"><span class="comment">         * </span></span><br><span class="line"><span class="comment">         * a-- --a同理</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        System.out.println(<span class="string">"a="</span> + a);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">int</span> b = a++;    <span class="comment">// b=a; a=a+1;</span></span><br><span class="line">        a = <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">int</span> c = ++a;    <span class="comment">// a=a+1; c=a;</span></span><br><span class="line">        System.out.println(<span class="string">"b="</span> + b);</span><br><span class="line">        System.out.println(<span class="string">"c="</span> + c);</span><br><span class="line">        </span><br><span class="line">        a = <span class="number">1</span>;</span><br><span class="line">        b = a--;    <span class="comment">// b=a; a=a-1;</span></span><br><span class="line">        System.out.println(<span class="string">"b="</span> + b);</span><br><span class="line">        a = <span class="number">1</span>;</span><br><span class="line">        c = --a;    <span class="comment">// a=a-1; c=a;</span></span><br><span class="line">        System.out.println(<span class="string">"c="</span> + c);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="12-数组"><a href="#12-数组" class="headerlink" title="12.数组"></a>12.数组</h3><p>java里面搜有点内容都是在内存中运行的；<br>要占用内存空间；<br>1 2 3 这些洞子必须放在某一个空间里面<br>int a = 1;<br>如果要有多个数字 1 2 3，一个一个输入需要输入三次，浪费时间，<br>一起输入可以节省空间，节省运行时间。</p>
<p>数组：<br>数组是用来存放某些相同类型元素的集合：<br>数组是一个集合（容器 可以存放多个）<br>数组里面可以存放任意数据类型（基本数据类型和引用数据类型）<br>数组里面存放的数据类型必须是一样的<br>数组一经创建，长度确定。  </p>
<h4 id="数组的声明"><a href="#数组的声明" class="headerlink" title="数组的声明"></a>数组的声明</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">数据类型 [] 数组名;</span><br><span class="line">数组名 = <span class="keyword">new</span> 数据类型[数组长度];</span><br></pre></td></tr></table></figure>

<p>执行顺序：  </p>
<ol>
<li>int[]    在内存中开辟了一个int类型的数组空间</li>
<li>a   给这个空间起个名字</li>
<li>a = new int[5];       把a代表的空间分成5份，并给这5个 空间加上编号。编号从0开始</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ArrayDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 数组的声明</span></span><br><span class="line"><span class="comment">         *      数据类型 [] 数组名:</span></span><br><span class="line"><span class="comment">         * 数组名 = new 数据类型[数组长度]</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">int</span> [] a;</span><br><span class="line">        a = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>];</span><br><span class="line">        <span class="comment">// 赋值 数组名[下标] = 值;</span></span><br><span class="line">        a[<span class="number">3</span>] = <span class="number">3</span>;</span><br><span class="line">        <span class="comment">// a[5] = 1;   //  java.lang.ArrayIndexOutOfBoundsException 数组索引越界</span></span><br><span class="line">        a[<span class="number">4</span>] = <span class="number">4</span>;</span><br><span class="line">        <span class="comment">// 修改值，直接赋值会覆盖前面的</span></span><br><span class="line">        a[<span class="number">4</span>] = <span class="number">6</span>;</span><br><span class="line">        <span class="comment">// 获取值</span></span><br><span class="line">        <span class="keyword">int</span> x = a[<span class="number">4</span>];</span><br><span class="line">        System.out.println(<span class="string">"a[4]="</span> + x);</span><br><span class="line">        <span class="comment">/* 获取数组的长度 数组名.length</span></span><br><span class="line"><span class="comment">         * 基本数据类型和引用数据类型的区别</span></span><br><span class="line"><span class="comment">         * 引用数据类型有自己的属性和方法，基本数据类型没有</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">int</span> l = a.length;</span><br><span class="line">        System.out.println(<span class="string">"数组a的长度为"</span> + l);</span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 数组的声明2</span></span><br><span class="line"><span class="comment">         * 数据类型 [] 数组名;</span></span><br><span class="line"><span class="comment">         * 数组名 = new 数据类型 [] &#123;元素1， 元素2，...&#125;;</span></span><br><span class="line"><span class="comment">         *</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="keyword">int</span> [] b = <span class="keyword">new</span> <span class="keyword">int</span>[]&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>&#125;;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">         * 数组的声明3</span></span><br><span class="line"><span class="comment">         * 数据类型 [] 数组名 = &#123;元素1， 元素2， 元素3&#125;;</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">        <span class="comment">// 遍历输入数组</span></span><br><span class="line">        <span class="keyword">int</span>[]c = &#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>&#125;;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;c.length;i++)&#123;</span><br><span class="line">            System.out.print(<span class="string">"c["</span> + i + <span class="string">"]="</span> + c[i] + <span class="string">" "</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        System.out.println();</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 求出数组里的最大值和最小值</span></span><br><span class="line">        <span class="keyword">int</span>[]d = &#123;<span class="number">3</span>, <span class="number">9</span>, <span class="number">23</span>, <span class="number">1</span>, <span class="number">5</span>, <span class="number">4</span>&#125;;</span><br><span class="line">        <span class="keyword">int</span> min_d = d[<span class="number">0</span>]; <span class="keyword">int</span>  max_d = d[<span class="number">0</span>];</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>; i&lt;d.length; i++)&#123;</span><br><span class="line">            <span class="keyword">if</span>(d[i]&gt;max_d)&#123;</span><br><span class="line">                max_d = d[i];</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(d[i]&lt;min_d)&#123;</span><br><span class="line">                min_d = d[i];</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        System.out.println(<span class="string">"数组d的最大值为"</span> + max_d + <span class="string">"，最小值为"</span> + min_d);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// x,y的值互换</span></span><br><span class="line">        <span class="keyword">int</span> x = <span class="number">1</span>;</span><br><span class="line">        <span class="keyword">int</span> y = <span class="number">2</span>;</span><br><span class="line">        <span class="keyword">int</span> t;</span><br><span class="line">        t = x; x = y; y = t;</span><br><span class="line">        System.out.println(<span class="string">"x的值为"</span> + x + <span class="string">", y的值为"</span> + y);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="13-数据类型转换"><a href="#13-数据类型转换" class="headerlink" title="13.数据类型转换"></a>13.数据类型转换</h3><ol>
<li><p>自动转换<br><strong>低精度数据类型</strong>赋值给<strong>高精度数据类型时</strong>会自动转换</p>
</li>
<li><p>强制转换<br><strong>高精度数据类型</strong>向<strong>低精度数据类型</strong>转换时需要强制转换  </p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> a = <span class="number">1</span>;</span><br><span class="line"><span class="keyword">byte</span> b = (<span class="keyword">byte</span>)a;</span><br><span class="line"><span class="keyword">byte</span> c = (<span class="keyword">byte</span>)<span class="number">10</span>;	<span class="comment">// 强制转化可以跟变量名，也可以直接是值</span></span><br></pre></td></tr></table></figure>

</li>
</ol>
<h2 id="排序"><a href="#排序" class="headerlink" title="排序"></a>排序</h2><h3 id="冒泡法排序"><a href="#冒泡法排序" class="headerlink" title="冒泡法排序"></a>冒泡法排序</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.zhiyou100.day05;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 冒泡法排序</span></span><br><span class="line"><span class="comment"> * 每次循环将最大的放到最右边</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">BubbleSort</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">int</span> [] a = &#123;<span class="number">5</span>, <span class="number">14</span>, <span class="number">3</span>, <span class="number">9</span>, <span class="number">6</span>, <span class="number">30</span>&#125;;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;a.length-<span class="number">1</span>;i++)&#123;</span><br><span class="line">            <span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>; j&lt;a.length-<span class="number">1</span>-i; j++)&#123;</span><br><span class="line">                <span class="keyword">int</span> temp;</span><br><span class="line">                <span class="keyword">if</span>(a[j] &gt; a[j+<span class="number">1</span>])&#123;</span><br><span class="line">                    temp = a[j+<span class="number">1</span>];</span><br><span class="line">                    a[j+<span class="number">1</span>] = a[j];</span><br><span class="line">                    a[j] = temp;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;a.length;i++)&#123;</span><br><span class="line">            System.out.println(a[i] + <span class="string">" "</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


    </div>

    
    
    
        <div class="reward-container">
  <div></div>
  <button disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/blog/images/wechat.png" alt="Asura 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/blog/images/alipay.jpg" alt="Asura 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>Asura
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://asura_99.gitee.io/blog/2020/01/07/java%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E5%8F%8A%E4%BE%8B%E5%AD%90/" title="java基本语法及例子">http://asura_99.gitee.io/blog/2020/01/07/java基本语法及例子/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/zh-CN" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/blog/tags/java/" rel="tag"><i class="fa fa-tag"></i> java</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/blog/2020/01/03/manjaro%E5%AE%89%E8%A3%85vscode%E5%8F%8Asublime-text/" rel="prev" title="manjaro安装vscode及sublime text">
      <i class="fa fa-chevron-left"></i> manjaro安装vscode及sublime text
    </a></div>
      <div class="post-nav-item">
    <a href="/blog/2020/01/07/java-%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" rel="next" title="java-面向对象">
      java-面向对象 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Java学习"><span class="nav-number">1.</span> <span class="nav-text">Java学习</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#新建项目"><span class="nav-number">1.1.</span> <span class="nav-text">新建项目</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#项目结构"><span class="nav-number">1.1.1.</span> <span class="nav-text">项目结构</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#编写代码"><span class="nav-number">1.2.</span> <span class="nav-text">编写代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Java的基本语法"><span class="nav-number">1.3.</span> <span class="nav-text">Java的基本语法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-关键字（50个）"><span class="nav-number">1.3.1.</span> <span class="nav-text">1. 关键字（50个）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-保留字"><span class="nav-number">1.3.2.</span> <span class="nav-text">2. 保留字</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-标识符"><span class="nav-number">1.3.3.</span> <span class="nav-text">3. 标识符</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#合法的标识符"><span class="nav-number">1.3.3.1.</span> <span class="nav-text">合法的标识符</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-标识符的命名规范"><span class="nav-number">1.3.4.</span> <span class="nav-text">4. 标识符的命名规范</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-注释"><span class="nav-number">1.3.5.</span> <span class="nav-text">5. 注释</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-数据类型"><span class="nav-number">1.3.6.</span> <span class="nav-text">6. 数据类型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-变量"><span class="nav-number">1.3.7.</span> <span class="nav-text">7. 变量</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#变量的命名"><span class="nav-number">1.3.7.1.</span> <span class="nav-text">变量的命名</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#8-运算符"><span class="nav-number">1.3.8.</span> <span class="nav-text">8.运算符</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#算术运算符"><span class="nav-number">1.3.8.1.</span> <span class="nav-text">算术运算符</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#条件运算符"><span class="nav-number">1.3.8.2.</span> <span class="nav-text">条件运算符</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#逻辑运算符"><span class="nav-number">1.3.8.3.</span> <span class="nav-text">逻辑运算符</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#9-流程控制语句"><span class="nav-number">1.3.9.</span> <span class="nav-text">9.流程控制语句</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#选择结构"><span class="nav-number">1.3.9.1.</span> <span class="nav-text">选择结构</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#循环结构"><span class="nav-number">1.3.9.2.</span> <span class="nav-text">循环结构</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#break-continue"><span class="nav-number">1.3.9.3.</span> <span class="nav-text">break, continue</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Scanner（键盘输入，-扫描器）"><span class="nav-number">1.3.9.4.</span> <span class="nav-text">Scanner（键盘输入， 扫描器）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#猜数字小游戏"><span class="nav-number">1.3.9.5.</span> <span class="nav-text">猜数字小游戏</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#ATM"><span class="nav-number">1.3.9.6.</span> <span class="nav-text">ATM</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#doWhile-循环"><span class="nav-number">1.3.9.7.</span> <span class="nav-text">doWhile 循环</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#while和do-while的区别"><span class="nav-number">1.3.9.7.1.</span> <span class="nav-text">while和do-while的区别</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#for循环"><span class="nav-number">1.3.9.8.</span> <span class="nav-text">for循环</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#10-print输出"><span class="nav-number">1.3.10.</span> <span class="nav-text">10.print输出</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#11-赋值运算"><span class="nav-number">1.3.11.</span> <span class="nav-text">11.赋值运算</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#12-数组"><span class="nav-number">1.3.12.</span> <span class="nav-text">12.数组</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#数组的声明"><span class="nav-number">1.3.12.1.</span> <span class="nav-text">数组的声明</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#13-数据类型转换"><span class="nav-number">1.3.13.</span> <span class="nav-text">13.数据类型转换</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#排序"><span class="nav-number">1.4.</span> <span class="nav-text">排序</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#冒泡法排序"><span class="nav-number">1.4.1.</span> <span class="nav-text">冒泡法排序</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Asura"
      src="http://tva1.sinaimg.cn/large/007X8olVly1g7ulgru7t4j30u00u0juk.jpg">
  <p class="site-author-name" itemprop="name">Asura</p>
  <div class="site-description" itemprop="description">有时候总觉得生活的矛盾让我们的生活丰富了许多：矛盾像首尾互接的鱼，在这个世界中长久地存活着。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">9</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/blog/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/blog/tags/">
          
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/LoverHZ" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;LoverHZ" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/Asura_99" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;Asura_99" rel="noopener" target="_blank"><i class="fa fa-fw fa-code"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:chenzhihao0126@gmail.com" title="E-Mail → mailto:chenzhihao0126@gmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="http://wpa.qq.com/msgrd?v=3&uin=1614482392&site=qq&menu=yes" title="QQ → http:&#x2F;&#x2F;wpa.qq.com&#x2F;msgrd?v&#x3D;3&amp;uin&#x3D;1614482392&amp;site&#x3D;qq&amp;menu&#x3D;yes" rel="noopener" target="_blank"><i class="fa fa-fw fa-qq"></i>QQ</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/zh-CN" class="cc-opacity" rel="noopener" target="_blank"><img src="/blog/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="https://gitee.com/Asura_99/blog" title="https:&#x2F;&#x2F;gitee.com&#x2F;Asura_99&#x2F;blog" rel="noopener" target="_blank">该Blog仓库</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Asura</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v4.2.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.7.0
  </div>

<span id="busuanzi_container_site_uv">
  本站访问次数：<span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
</span>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  
  <script color='0,0,255' opacity='0.5' zIndex='-1' count='99' src="/blog/lib/canvas-nest/canvas-nest.min.js"></script>
  <script src="/blog/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>

<script src="/blog/js/bookmark.js"></script>


  <script defer src="/blog/lib/three/three.min.js"></script>
    <script defer src="/blog/lib/three/canvas_lines.min.js"></script>


  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>




  
<script src="/blog/js/local-search.js"></script>













  

  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el: '#valine-comments',
      verify: true,
      notify: true,
      appId: 'YMFj5UPx2NLmJIieNQTjU9qg-gzGzoHsz',
      appKey: 'IhhqkMVc0p7hH5BBICARymuG',
      placeholder: "快留下你的评论吧！",
      avatar: 'mm',
      meta: guest,
      pageSize: '10' || 10,
      visitor: false,
      lang: 'zh-cn' || 'zh-cn',
      path: location.pathname,
      recordIP: false,
      serverURLs: ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
